import { I18N_MESSAGES_README } from "@/utils/i18n/i18n-readme.ts";
import { createI18n } from "vue-i18n";
import { getLang } from "@/utils/storages/i18n.ts";
import { I18N_PRIVACY_POLICY } from "@/utils/i18n/i18n-privacy-policy.ts";

export const I18N_MESSAGES = {
  en: {
    btn_confirm: "Confirm",
    btn_edit_script: "Edit Script",
    btn_readme_directory: "Directory",
    btn_request_diff: "View diff results",
    btn_reset: "Reset",
    btn_select_file: "Select File",
    btn_select_file_label: "File {filename}:",
    btn_select_file_required: "Please select the file!",
    btn_select_github_file_label: "Only files with changes are loaded",
    diff_display_aligned: "Align",
    diff_display_compact: "Compact",
    diff_legend_add: "Add",
    diff_legend_block_copy: "Block copy",
    diff_legend_block_move: "Block move",
    diff_legend_delete: "Delete",
    diff_legend_merge: "Merge",
    diff_legend_split: "Split",
    diff_legend_update: "Update",
    diff_no_difference: "No difference",
    diff_no_github_modified_file: "No Modified Files",
    diff_setting: "Settings",
    mdfy_added_successfully:
      "Added successfully, click the `{button}` button to reload differences",
    mdfy_cleared: "Data cleared",
    mdfy_data_error: "Data error",
    mdfy_execute_start: "start overwriting diff data",
    mdfy_executed_item: "Overwritten diff data: {overwritten}",
    mdfy_executed_item_not_found: "Diff data not found: {diff}",
    mdfy_first_parameter_error: "The first parameter is invalid",
    mdfy_second_parameter_error: "The second parameter is invalid",
    readme: I18N_MESSAGES_README.en,
    privacy_policy: I18N_PRIVACY_POLICY.en,

    setting_general__git_diff_algo: "Git diff algorithm",
    setting_general__tab_size: "Tab size",
    setting_updates__identify: "Identify updates",
    setting_updates__ctx_length: "Context length",
    setting_updates__line_sim_weight: "Line similarity weight",
    setting_updates__line_sim_threshold: "Synthetic line-similarity threshold",
    setting_splits__identify: "Identify splits",
    setting_splits__max_split_lines: "Maximal number of splitting lines",
    setting_merges__identify: "Identify merges",
    setting_merges__max_merge_lines: "Maximal number of merging lines",
    setting_moves__identify: "Identity block moves",
    setting_moves__min_block_length: "Minimal moving-block length",
    setting_moves__identify_updates: "Identity updates in block moves",
    setting_moves__record_stop_words: "Record lines only containing stop words in block moves",
    setting_copies__identify: "Identity block copies",
    setting_copies__min_block_length: "Minimal copying-block length",
    setting_copies__identify_updates: "Identity updates in block copies",
    setting_copies__record_stop_words: "Record lines only containing stop words in block copies",

    symbol_colon: ": ",
    page_title: "BDiff File Differencing Tool",
    xhr_failed_to_get_diff: "Failed to get diff data!",
    xhr_failed_to_get_github_files: "Failed to get GitHub files!",
    xhr_failed_to_get_github_files_contents: "Failed to get GitHub files Contents!",
    xhr_failed_to_upload_file: "File upload failed: {msg}",
  },
  zh: {
    btn_confirm: "确定",
    btn_edit_script: "编辑脚本",
    btn_readme_directory: "目录",
    btn_request_diff: "查看差异结果",
    btn_reset: "重置",
    btn_select_file: "选择文件",
    btn_select_file_label: "文件{filename}：",
    btn_select_file_required: "请先选择文件！",
    btn_select_github_file_label: "仅加载有变更的文件",
    diff_display_aligned: "对齐",
    diff_display_compact: "紧凑",
    diff_legend_add: "新增",
    diff_legend_block_copy: "复制",
    diff_legend_block_move: "移动",
    diff_legend_delete: "删除",
    diff_legend_merge: "合并",
    diff_legend_split: "分割",
    diff_legend_update: "更新",
    diff_no_difference: "没有差异",
    diff_no_github_modified_file: "没有可加载的文件",
    diff_setting: "设置",
    mdfy_added_successfully: "添加成功，点击`{button}`按钮重新加载差异",
    mdfy_cleared: "数据已清空",
    mdfy_data_error: "数据有误",
    mdfy_execute_start: "开始覆写差异数据",
    mdfy_executed_item: "已覆写数据：{overwritten}",
    mdfy_executed_item_not_found: "未找到差异数据：{diff}",
    mdfy_first_parameter_error: "第一个参数格式有误",
    mdfy_second_parameter_error: "第二个参数格式有误",
    readme: I18N_MESSAGES_README.zh,
    privacy_policy: I18N_PRIVACY_POLICY.zh,

    setting_general__git_diff_algo: "Git差异算法",
    setting_general__tab_size: "制表符长度",
    setting_updates__identify: "识别块更新",
    setting_updates__ctx_length: "上下文长度",
    setting_updates__line_sim_weight: "行相似度权重",
    setting_updates__line_sim_threshold: "综合行相似度临界值",
    setting_splits__identify: "识别块分割",
    setting_splits__max_split_lines: "最大分割行数",
    setting_merges__identify: "识别块合并",
    setting_merges__max_merge_lines: "最大合并行数",
    setting_moves__identify: "识别块移动",
    setting_moves__min_block_length: "移动块最小长度",
    setting_moves__identify_updates: "识别移动块更新",
    setting_moves__record_stop_words: "纯停用词行计入移动块大小",
    setting_copies__identify: "识别块复制",
    setting_copies__min_block_length: "复制块最小长度",
    setting_copies__identify_updates: "识别复制块更新",
    setting_copies__record_stop_words: "纯停用词行计入复制块大小",

    symbol_colon: "：",
    page_title: "BDiff文本差异工具",
    xhr_failed_to_get_diff: "获取 diff 数据失败！",
    xhr_failed_to_get_github_files: "获取 GitHub 文件失败！",
    xhr_failed_to_get_github_files_contents: "获取 GitHub 文件内容失败！",
    xhr_failed_to_upload_file: "文件上传失败：{msg}",
  },
} as const;

export type I18N_LANGS = keyof typeof I18N_MESSAGES;

export const i18n = createI18n({
  locale: getLang(),
  fallbackLocale: getLang(),
  messages: I18N_MESSAGES,
  warnHtmlInMessage: "off",
});
